import requests
import re

#url地址
# 案例：登录后，访问个人信息页
id=1
username='wangjiacheng01'
password='123456'
vericode='shtd'
url_first=r'http://172.16.22.104:8080/bsams/front/login.do'
url_vericode=r'http://172.16.22.104:8080/bsams/front/vericode.do'
url_info=r'http://172.16.22.104:8080/bsams/front/asset/asset_list.do'
data={
    'taskId':id,
    'loginName':username,
    'password':password,
    'vericode':vericode
}
#发送请求
s=requests.Session()
s.get(url_first)
s.get(url_vericode)
s.post(url_first,data=data)

#访问资产管理页面
resp=s.get(url_info)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp.text)
print(title)

# 案例：资产管理 - 新增
url_new=r'http://172.16.22.104:8080/bsams/front/asset/asset_new.do?pageNo=1'
url_save=r'http://172.16.22.104:8080/bsams/front/asset/asset_new_save.do'
url_list=r'http://172.16.22.104:8080/bsams/front/asset/asset_list.do'
headers={
    'Cookie':'JSESSIONID=B483BECCBD66E056ED19C7CE47837CD6'
}
data={
    'title':'腾讯云aaa',
    'storageId':1,
    'providerId':1
}
#发送请求
s=requests.Session()
s.get(url_new)
s.post(url_save,data=data)
res=s.get(url_list,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,res.text)
print(title)
# 案例：资产管理 - 修改
url_update=r'http://172.16.22.108:8080/bsams/front/asset/asset_update.do?id=1800&pageNo=1'
url_update_save=r'http://172.16.22.108:8080/bsams/front/asset/asset_update_save.do'

data={
    'id':'1800',
    'title':'腾讯aa',
    'storageId':1,
    'providerId':1
}
s=requests.Session()
s.get(url_update)
s.post(url_update_save,data=data)
resp1=s.get(url_list,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp1.text)
print(title)


# 案例：资产管理 - 查询
url_query='http://172.16.22.108:8080/bsams/front/asset/asset_list.do'
data={
    'status': 1,
    'title': '腾讯'
}

s=requests.Session()
s.get(url_list)
resp2=s.post(url_query,data=data,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp2.text)
print(title)

# 案例：资产管理 - 借用
url_borrow='http://172.16.22.108:8080/bsams/front/asset/asset_update.do?id=1800&pageNo=1'
url_borrow_save=r'http://172.16.22.108:8080/bsams/front/asset/asset_borrow_save.do'
data={
    'id': 1800,
    'departId': 1,
    'remark': 111
}
s=requests.Session()
s.get(url_borrow)
s.post(url_borrow_save,data=data)
resp3=s.get(url_list,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp3.text)
print(title)

# 案例：资产管理 - 归还
url_giveBack=r'http://172.16.22.108:8080/bsams/front/asset/asset_giveBack.do?assetId=1800&_=1704889943493'
url_giveBack_save=r'http://172.16.22.108:8080/bsams/front/asset/asset_giveBack_save.do'
url_list=r'http://172.16.22.108:8080/bsams/front/asset/asset_list.do?pageNo=1'
data={
    'assetId': 1800
}
s=requests.Session()
s.get(url_giveBack)
s.post(url_giveBack_save,data=data,headers=headers)
resp4=s.get(url_list,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp4.text)
print(title)

# 案例：存放地点 - 查询
url_storage=r'http://172.16.22.108:8080/bsams/front/asset_storage/asset_storage_list.do'
url_storage_query=r'http://172.16.22.108:8080/bsams/front/asset_storage/asset_storage_list.do'
data={
    'status': 1,
    'title': 'a'
}
s=requests.Session()
s.get(url_storage)
resp5=s.post(url_storage_query,data=data,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp5.text)
print(title)
# 案例：供应商 - 查询
url_provider=r'http://172.16.22.108:8080/bsams/front/asset_provider/asset_provider_list.do'
url_provider_query=r'http://172.16.22.108:8080/bsams/front/asset_provider/asset_provider_list.do'
data={
    'status': 1,
    'title': 'a'
}
s=requests.Session()
s.get(url_provider)
resp6=s.post(url_provider_query,data=data,headers=headers)
patt=r'<title>(.*?)</title>'
title=re.findall(patt,resp6.text)
print(title)